const signUpButton = document.getElementById("signUp");
const signInButton = document.getElementById("signIn");
const container = document.getElementById("container");
const toLogin = document.getElementById("toLogin");
const toRegister = document.getElementById("toRegister");
let code_img1 = document.getElementById("code_img1");
let code_img0 = document.getElementById("code_img0");
sessionStorage.clear();
signUpButton.addEventListener("click", () => {
  container.classList.add("right-panel-active");
  console.log(66)
  code_img1.src = "/user/checkCode?date=" + new Date();
});

signInButton.addEventListener("click", () => {
  container.classList.remove("right-panel-active");
  code_img0.src = "/user/checkCode?date=" + new Date();
});
toLogin.addEventListener("click",()=>{
  let account_str=document.getElementById("u_account").value;
  if(account_str===null||account_str===""){
    alert("请输入账号");
    location.reload();
  }
  let pwd_str=document.getElementById("u_pwd").value;
  if(pwd_str===null||pwd_str===""){
    alert("请输入密码");
    location.reload();
  }
  let code_str=document.getElementById("u_code0").value;
  if(code_str===null||code_str===""){
    alert("请输入验证码");
    location.reload();
  }
})
toRegister.addEventListener("click",(e)=>{
  let account_str=document.getElementById("r_account").value;
  if(account_str===null||account_str===""){
    alert("请输入账号");
    e.preventDefault();
    return;
  }
  let name_str=document.getElementById("r_name").value;
  if(name_str===null||name_str===""){
    alert("请输入用户名");
    e.preventDefault();
    return;
  }
  let pwd_str=document.getElementById("r_pwd").value;
  if(pwd_str===null||pwd_str===""){
    alert("请输入密码");
    e.preventDefault();
    return;
  }
  let rpwd_str=document.getElementById("r_rpwd").value;
  if(rpwd_str===null||rpwd_str===""){
    alert("请输入确认密码");
    e.preventDefault();
    return;
  }
  let code_str=document.getElementById("u_code1").value;
  if(code_str===null||code_str===""){
    alert("请输入验证码");
    location.reload();
  }
  if(rpwd_str !== pwd_str){
    alert("两次输入密码不一致");
    e.preventDefault();
    return;
  }
})

code_img0.addEventListener("click",()=>{
  console.log(66)
  code_img0.src = "/user/checkCode?date=" + new Date();
})

code_img1.addEventListener("click",()=>{
  code_img1.src = "/user/checkCode?date=" + new Date();
})
